<!--#include file="pjson.asp"-->
<!DOCTYPE html>
<html>
<head>
  <title>设备管理</title>
<%
sessionExpire
easp.include "h.asp"
%>
</head>
<body>
<%
' t_define
%>
  <div class="layui-fluid">
    <div class="layui-card"><br>
      <div class="layui-form layui-card-header layuiadmin-card-header-auto">
        <div class="layui-form-item">
          <div class="layui-inline">			
            <%
            s1 "select id as typ from baseinfo where mode='设备类型'"
			echo myopt2_no_required("typ","设备类型",sql2arr("select id,name1 from baseinfo where mode='设备类型' "),val("typ"))
            %>
           </div>
          <div class="layui-inline">
            <label class="layui-form-label">检索</label>
            <div class="layui-input-block">
              <input type="text" name="prn_search" class="layui-input">
            </div>
          </div>
          <div class="layui-inline">
            <button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="prn_search">
              <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
            </button>
 			  <button type="button" class="layui-btn" lay-submit lay-filter="prn_add">新增</button>			
 			  <button type="button" class="layui-btn" lay-submit lay-filter="equipmentName_hand">型号维护</button>			
         </div>
        </div>
      </div>

      <div class="layui-card-body">
		<script type="text/html" id="barDemo">
			<a class="layui-btn layui-btn-xs" lay-event="prn_log1">提交工单</a>
			<a class="layui-btn layui-btn-xs" lay-event="prn_edit">修改</a>
			<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="prn_del">删除</a>			
		</script>
		<table id="prn" lay-filter="prn"></table><br>
      </div>
    </div>
  </div>
  <script src="/<%=rootpath%>/src/layuiadmin/layui/layui.js"></script>  
  <script>
  layui.config({
    base: '/<%=rootpath%>/src/layuiadmin/'
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'useradmin', 'table'], function(){
    var $ = layui.$
    ,form = layui.form
    ,admin = layui.admin	
    ,table = layui.table;
    form.render();
	var is_ks=false;	
    form.on('submit(prn_search)', function(data){
      var field = data.field;
	  var data1 = $("#sel_typ").val() ;
	  if(data1==1028){//选中科室
		is_ks=true;
	  }else{
		is_ks=false;
	  }	
	  table.reload('prn', {
        where: field
      });
        layer.msg('已刷新');	  
    });	
	table.render({
        elem: '#prn',
        url: 'pjson.asp?action=prn_l',
        cols: [[
		{type:'checkbox'},		
        {field: 'id',title: 'ID',width: 60,sort: true,hide:false},
		<%g_tbf "department,local,machineNo,ipadr:150,equipmentTypeId,equipmentName:180","病区,地点,机器号,ip地址,类别号,型号"%>
        {fixed: 'right',width: 200,align: 'center',toolbar: '#barDemo'}]],
		 done: function(res, curr, count){
				if(is_ks){//选中科室，隐藏列，修改列名
					$("[data-field='department']").attr('class','layui-hide layui-unselect');
					$("[data-field='machineNo']").css('display','none'); 
					$("[data-field='ipadr']").css('display','none'); 
					$("[data-field='equipmentName']").find('span').text('科室');
				}
				},
		
        id: 'prn',
        limit: 10,
        page: true,
        height: 475
    });
    form.on('submit(equipmentName_hand)', function(data){
		$(location).attr('href',"equipmentType_l.asp?typ=");  
    });	

    form.on('submit(prn_add)', function(data){
      layer.open({
        type: 2,title: '新增',content: 'prn_frm.asp?now=' + new Date().getTime() +"&type=prn"+"&typ="+$('#sel_typ').val() ,maxmin: true
        ,area: ['500px', '450px']
        ,btn: ['确定', '取消']
        ,yes: function(index, layero){
          var iframeWindow = window['layui-layer-iframe'+ index]
          ,submitID = 'LAY-user-front-submit'
          ,submit = layero.find('iframe').contents().find('#'+ submitID);
          iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
            var field = data.field; 
				$.post('pjson.asp?now=' + new Date().getTime(), {
					action: "prn_add",
					field
				},
				function(data) {
					layer.msg($.parseJSON(data).msg);
				});
            table.reload('prn'); 
            layer.close(index); 
          });  
          submit.trigger('click');
        }
        ,success: function(layero, index){
        }
      });	
    });	
 
    table.on('tool(prn)',
    function(obj) {
        var data = obj.data;
		if (obj.event === 'prn_edit') {
			var _this = $(this);
			  layer.open({
				type: 2
				,title: '修改'
				,content: 'prn_frm.asp?now=' + new Date().getTime()+"&id="+data.id
				,maxmin: true
				,area: ['500px', '450px']
				,btn: ['确定', '取消']
				,yes: function(index, layero){
				  var iframeWindow = window['layui-layer-iframe'+ index]
				  ,submitID = 'LAY-user-front-submit'
				  ,submit = layero.find('iframe').contents().find('#'+ submitID);
				  iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
					var field = data.field; 
						$.post('pjson.asp?now=' + new Date().getTime(), {
							action: "prn_upd",id:data.id,
							field
						},
						function(data) {
							layer.msg($.parseJSON(data).msg);
						});
					table.reload('prn'); //数据刷新
					layer.close(index); //关闭弹层
				  });  
				  submit.trigger('click');
				}
				,success: function(layero, index){
				}
				});				
			table.reload('prn');
		}		
		else if (obj.event === 'prn_del') {
			var _this = $(this);
			layer.confirm('您确定删除此信息？' + data.id, {
				icon: 3,
				title: '提示信息'
			},
			function(index) {
				$.post('pjson.asp?now=' + new Date().getTime(), 
				{
					id: data.id
					,action: "prn_del"
				},
				function(data) {
					layer.msg($.parseJSON(data).msg);
				});
				layer.close(index);
				table.reload('prn');				
			});
		}	
		else if (obj.event === 'prn_log1') {
			var _this = $(this);
			$(location).attr('href',"prn_post.asp?equipmentid="+data.id);  
		}
	});		
  });
  </script>
</body>
</html>